package welsir.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import welsir.entity.dos.Disease;
import welsir.entity.dos.Seeding;
import welsir.entity.vo.DiseasePageVO;
import welsir.entity.vo.SeedingPageVO;
import welsir.entity.vo.SeedingVO;
import welsir.mapper.DiseaseMapper;
import welsir.mapper.SeedingMapper;
import welsir.service.IDiseaseService;
import welsir.service.ISeedingService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Genius
 * @date 2023/03/19 14:39
 **/
@Service
@Slf4j
public class IDiseaseServiceImpl extends ServiceImpl<DiseaseMapper, Disease> implements IDiseaseService {
    @Resource
    private DiseaseMapper diseaseMapper;

    @Override
    public DiseasePageVO VoList(Integer page, Integer size) {
        Page<Disease> diseasePage = new Page<>(page,size);

        QueryWrapper<Disease> wrapper= new QueryWrapper<Disease>();
        wrapper.orderByDesc("id");

        Page<Disease> resultPage = this.diseaseMapper.selectPage(diseasePage, wrapper);


        List<Disease> diseases = resultPage.getRecords();

        DiseasePageVO diseasePageVO = new DiseasePageVO();
        diseasePageVO.setData(diseases);
        diseasePageVO.setTotal(resultPage.getTotal());
        diseasePageVO.setPages(resultPage.getPages());
        return diseasePageVO;
    }
}
